#include "picturerender.h"
#include "../texture/texture2d.h"

void SinglePictureRender::render(GLfloat x,GLfloat y)
{
    if(m_useTransparency)
    {
        glEnable(GL_BLEND);
        glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
    }

    Point position{x,y};
    Size picSize = m_picture->getSize();
    PersonalTexture::Texture2D::DrawTexture(m_picture->getTexture(),&position,&picSize);

    if(m_useTransparency)
    {
        glDisable(GL_BLEND);
    }
}

void MultiPictureRender::update()
{
    m_currentPictureIndex++;

    if(m_currentPictureIndex >= m_picture->getTextureIndex())
    {
        m_currentPictureIndex = 0;
    }
}

void MultiPictureRender::render(GLfloat x,GLfloat y)
{
    if(m_useTransparency)
    {
        glEnable(GL_BLEND);
        glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
    }


    Point position{x,y};
    Size picSize = m_picture->getSize();
    PersonalTexture::Texture2D::DrawTexture(m_picture->getTexture(m_currentPictureIndex),&position,&picSize);


    if(m_useTransparency)
    {
        glDisable(GL_BLEND);
    }
}
